<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<c:if test="${!scheduleMap.containsKey(dayhour) and !restMap.containsKey(dayhour)}">
  <div class="item  available">
    <c:set var="amount" value="${remainCoaches[dayhour]}"/>
    <c:set var="roomRecord" value="${roomRecords[dayhour] == null ? 0 : roomRecords[dayhour]}"/>
    <c:set var="commonRecord" value="${commonRecords[dayhour] == null ? 0 : commonRecords[dayhour]}"/>
    <c:set var="couldAppoint" value="${(currentSite.roomLimit.roomLimit - roomRecord > 0 && amount > 0) || (currentSite.roomLimit.commonLimit - commonRecord > 0 && amount > 0)}"/>
    <a href="javascript:void(0);"  data-date='<fmt:formatDate value="${currentDay}" pattern="yyyy/MM/dd" />'
                                   data-datevalue="${currentDayString}"
                                   data-time="${hourPerfix}${hour}:00"
                                   data-room="${currentSite.roomLimit.roomLimit > 0 ? currentSite.roomLimit.roomLimit - roomRecord < amount ? currentSite.roomLimit.roomLimit - roomRecord : amount : '-1'}" 
                                   data-common="${currentSite.roomLimit.commonLimit > 0 ? currentSite.roomLimit.commonLimit - roomRecord < amount ? currentSite.roomLimit.commonLimit - roomRecord : amount : '-1'}">
      <p class="time">
        ${hourPerfix}${hour}:00~${afterhourPerfix}${hour + 1}:00<br/>
        <c:if test="${currentSite.roomLimit.roomLimit > 0}">
           私人区域：${currentSite.roomLimit.roomLimit - roomRecord < amount ? currentSite.roomLimit.roomLimit - roomRecord : amount}<br>
        </c:if>
        <c:if test="${currentSite.roomLimit.commonLimit > 0}">
           ${currentSite.fuxing ? '米域' : '公共区域' }：${currentSite.roomLimit.commonLimit - commonRecord < amount ? currentSite.roomLimit.commonLimit - commonRecord : amount}
        </c:if>
      </p>
      <p class="tips ${couldAppoint ? 'color-green' : 'color-red'}">
        ${couldAppoint ? '可预约' : '已满'}
      </p>
    </a>
  </div>
</c:if>
<c:if test="${!scheduleMap.containsKey(halfhour) and !restMap.containsKey(halfhour) and (hour != appointEndTime[0]-1 or isEndHour)}">
  <div class="item  available">
    <c:set var="amount" value="${remainCoaches[halfhour]}"/>
    <c:set var="roomRecord" value="${roomRecords[halfhour] == null ? 0 : roomRecords[halfhour]}"/>
    <c:set var="commonRecord" value="${commonRecords[halfhour] == null ? 0 : commonRecords[halfhour]}"/>
    <c:set var="couldAppoint" value="${(currentSite.roomLimit.roomLimit - roomRecord > 0 && amount > 0) || (currentSite.roomLimit.commonLimit - commonRecord > 0 && amount > 0)}"/>
    <a href="#"  data-date='<fmt:formatDate value="${currentDay}" pattern="yyyy/MM/dd" />'
                 data-datevalue="${currentDayString}" 
                 data-time="${hourPerfix}${hour}:30" 
                 data-room="${currentSite.roomLimit.roomLimit > 0 ? currentSite.roomLimit.roomLimit - roomRecord < amount ? currentSite.roomLimit.roomLimit - roomRecord : amount : '-1'}" 
                 data-common="${currentSite.roomLimit.commonLimit > 0 ? currentSite.roomLimit.commonLimit - roomRecord < amount ? currentSite.roomLimit.commonLimit - roomRecord : amount : '-1'}">
      <p class="time">
        ${hourPerfix}${hour}:30~${afterhourPerfix}${hour + 1}:30<br/>
        <c:if test="${currentSite.roomLimit.roomLimit > 0}">
           私人区域：${currentSite.roomLimit.roomLimit - roomRecord < amount ? currentSite.roomLimit.roomLimit - roomRecord : amount}<br>
        </c:if>
        <c:if test="${currentSite.roomLimit.commonLimit > 0}">
          ${currentSite.fuxing ? '米域' : '公共区域' }：${currentSite.roomLimit.commonLimit - commonRecord < amount ? currentSite.roomLimit.commonLimit - commonRecord : amount}
        </c:if>
      </p>
      <p class="tips ${couldAppoint ? 'color-green' : 'color-red'}">
        ${couldAppoint ? '可预约' : '已满'}
      </p>
    </a>
  </div>
</c:if>

